\def\fileversion{v1.1}
\def\filedate{2001/07/12}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Giuseppe Bilotta
%
% Phone +39-095-338103
%
% Email: bourbaki@bigfoot.com
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This package is distributed under the terms
% of the LaTeX Project Public License
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Please read the readme.txt file for details
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{byname}[\filedate\space\fileversion\space Increase
reference capability (reference by name)]
%
\newcommand*{\byn@melabel}[2]{%
    \def\@currnamelabel{{#1}{#2}}}

\let\bns@vesect=\@sect

\def\@sect#1#2#3#4#5#6[#7]#8{%
    \bns@vesect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}%
    \byn@melabel{#7}{#8}}

\let\bns@vechap=\@chapter
\def\@chapter[#1]#2{%
    \bns@vechap[#1]{#2}%
    \byn@melabel{#1}{#2}}

% Hack label: also write the NameRef data ...
\def\newnamelabel{\@newl@bel {name}}
%save previous \label
\AtBeginDocument{\let\nr@ldlabel=\label
\renewcommand*{\label}[1]{\nr@ldlabel{#1}%
    \@bsphack%
    \protected@write\@auxout{}%
        {\string\newnamelabel{#1}{\@currnamelabel}}%
    \@esphack}}
% Reference by name
%
\@ifpackageloaded{hyperref}{%
   \newcommand*{\byname}[1]{%
       \expandafter\real@setref\csname name@#1\endcsname\@secondoftwo{#1}%
       }
   \newcommand*{\byshortname}[1]{%
       \expandafter\real@setref\csname name@#1\endcsname\@firstoftwo{#1}%
       }
   }{
   \newcommand*{\byname}[1]{%
       \expandafter\@setref\csname name@#1\endcsname\@secondoftwo{#1}%
       }
   \newcommand*{\byshortname}[1]{%
       \expandafter\@setref\csname name@#1\endcsname\@firstoftwo{#1}%
       }
   }
\endinput
